import { Component } from 'react';
import bus from '../../util/bus';
import { BrowserRouter, Link, NavLink, Route, Switch, Redirect } from 'react-router-dom';
import './Header.css'

export default class Header extends Component {

  logindplay = () => {
    console.log(typeof this.props.useremail)
    console.log(this.props.useremail)
    bus.emit("logindplay");
  }

  logout = () => {
    this.props.deleteEmail();
  }

  render () {
    const {useremail} = this.props;
    return (
      <div id="header">
        
        <Link className="but" onClick={this.logindplay} to='/logAndRe' style={{display: useremail === '' ? "block" : "none"}}> 登录</Link>
        {/* <button id="but" onClick={this.logindplay}>登录</button>*/}
        <Link className="but logout" onClick={this.logout} to='/home' style={{display: useremail !== '' ? "block" : "none"}}> 退出登录</Link>
        <span className="useremail">{useremail}</span>
      </div>
    )
  }

}